home *** CD-ROM | disk | FTP | other *** search
/ Sprite 1984 - 1993 / Sprite 1984 - 1993.iso / lib / pmake / bigcmd.mk < prev    next >
Makefile  |  1992-04-13  |  6KB  |  233 lines

  1. #
  2. # Included makefile for creating a kernel module.
  3. # Variables provided by Makefile that includes this one:
  4. #    NAME        module name
  5. #    SRCS        all sources for the module for the current target
  6. #            machine
  7. #    ALLSRCS        all sources for the module, including all sources
  8. #            for all target machines (used for ctags)
  9. #    OBJS        object files from which to create the module
  10. #    CLEANOBJS    object files to be removed as part of "make clean"
  11. #            (need not just be object files)
  12. #    HDRS        all header files for the module
  13. #    TM        target machine type for object files etc.
  14. #    MACHINES    list of all target machines currently available
  15. #            for this program.
  16. #
  17. # $Header: /sprite/lib/pmake/RCS/bigcmd.mk,v 1.28 92/04/13 18:32:58 elm Exp $ SPRITE (Berkeley)
  18. #
  19.  
  20. #
  21. # The variables below should be defined in md.mk, but they are given
  22. # default values just in case md.mk doesn't exist yet.
  23. #
  24. SRCS        ?=
  25. OBJS        ?=
  26. HDRS        ?=
  27.  
  28. CSRCS        ?= $(SRCS:M*.c)
  29. SSRCS        ?= $(SRCS:M*.s)
  30. POBJS        ?= $(OBJS:S/.o$/.po/g)
  31. ALLCSRCS    ?= $(ALLSRCS:M*.c)
  32.  
  33. #
  34. # Define search paths for libraries, include files and lint libraries
  35. #
  36. .PATH.a        :
  37. .PATH.h        :
  38. .PATH.h        : $(TM).md /sprite/lib/include /sprite/lib/include/$(TM).md
  39. .PATH.ln    : 
  40. .PATH.ln    : /sprite/lib/lint
  41. .PATH.c        :
  42. .PATH.c        : $(TM).md
  43. .PATH.s        :
  44. .PATH.s        : $(TM).md
  45.  
  46. #
  47. # Important directories. 
  48. #
  49. BINDIR        = /sprite/cmds.$(MACHINE)
  50.  
  51. #
  52. # System programs -- assign conditionally so they may be redefined in
  53. # including makefile.
  54. #
  55. AS        ?= $(BINDIR/as
  56. CC        ?= $(BINDIR)/cc
  57. CP        ?= $(BINDIR)/cp
  58. CPP        ?= $(BINDIR)/cpp -traditional -$
  59. CTAGS        ?= $(BINDIR)/ctags
  60. LD        ?= $(BINDIR)/ld.new
  61. LINT        ?= $(BINDIR)/lint
  62. MAKEDEPEND    ?= $(BINDIR)/makedepend
  63. MV        ?= $(BINDIR)/mv
  64. RM        ?= $(BINDIR)/rm
  65. SED        ?= $(BINDIR)/sed
  66. TEST            ?= $(BINDIR)/test
  67. TOUCH        ?= $(BINDIR)/touch
  68. UPDATE        ?= $(BINDIR)/update
  69.  
  70. #
  71. # Figure out what stuff we'll pass to sub-makes.
  72. #
  73. PASSVARS    = 'INSTALLDIR=$(INSTALLDIR)' $(.MAKEFLAGS)
  74. #ifdef        XCFLAGS
  75. PASSVARS    += 'XCFLAGS=$(XCFLAGS)'
  76. #endif
  77. #ifdef        XAFLAGS
  78. PASSVARS    += 'XAFLAGS=$(XAFLAGS)'
  79. #endif
  80.  
  81. #
  82. # Flags. These are ones that are needed by *all* modules. Any other
  83. # ones should be added with the += operator in local.mk files.
  84. # The FLAGS variables are defined with the += operator in case this file
  85. # is included after the main makefile has already defined them...
  86. #
  87.  
  88. #include    <tm.mk>
  89. CTFLAGS        ?= -wt
  90. INSTALLFLAGS    ?=
  91. LINTFLAGS    ?= -m$(TM) 
  92. LINTFLAGS    += -u -M
  93. XCFLAGS        ?=
  94. XAFLAGS        ?=
  95. #
  96. # The .INCLUDES variable already includes directories that should be
  97. # used by cc and other programs by default.  Remove them, just so that
  98. # the output looks cleaner.
  99. #
  100. # The ds3100 compiler doesn't include /sprite/lib/include, so we must leave
  101. # the path as is when TM=ds3100.  Also, the ds3100 port isn't ready for the -O
  102. # flag yet.
  103. #
  104.  
  105. #include <debugflags.mk>
  106.  
  107. CFLAGS        += $(GFLAG) ${OFLAG} $(TMCFLAGS) $(XCFLAGS) -I.
  108. CFLAGS        += $(.INCLUDES:S|^-I/sprite/lib/include$||g:S|^-I/sprite/lib/include/$(TM).md$||g)
  109. #if !empty(TM:Mds3100) 
  110. CFLAGS        += -I/sprite/lib/include -I/sprite/lib/include/$(TM).md
  111. #endif
  112. AFLAGS        += $(TMAFLAGS) $(XAFLAGS)
  113.  
  114. #
  115. # Transformation rules: these have special features to place .o files
  116. # in md subdirectories, run preprocessor over .s files, and generate
  117. # .po files for profiling.
  118. #
  119.  
  120. .SUFFIXES    : .po
  121.  
  122. .c.o        :
  123.     $(RM) -f $(.TARGET)
  124.     $(CC) $(CFLAGS) -c $(.IMPSRC) -o $(.TARGET)
  125. .c.po        :
  126.     $(RM) -f $(.TARGET)
  127.     $(CC) $(CFLAGS) -DPROFILE -c $(.IMPSRC) -o $(.TARGET)
  128. .cc.o        :
  129.     $(RM) -f $(.TARGET)
  130.     $(CPLUSPLUS) $(CFLAGS) -c $(.IMPSRC) -o $(.TARGET)
  131. .cc.po        :
  132.     $(RM) -f $(.TARGET)
  133.     $(CPLUSPLUS) $(CFLAGS) -DPROFILE -c $(.IMPSRC) -o $(.TARGET)
  134. .s.po .s.o    :
  135. #if empty(TM:Mds3100) && empty(TM:Mds5000)
  136.     $(CPP) $(CFLAGS:M-[IDU]*) -m$(TM) -D$(TM) -D_ASM $(.IMPSRC) > $(.PREFIX).pp
  137.     $(AS) -o $(.TARGET) $(AFLAGS) $(.PREFIX).pp
  138.     $(RM) -f $(.PREFIX).pp
  139. #else
  140.     $(RM) -f $(.TARGET)
  141.     $(AS) $(AFLAGS) $(.IMPSRC) -o $(.TARGET)
  142. #endif
  143.  
  144. #
  145. # MAKEDEPEND usage:
  146. #    <dependency-file> : <sources> MAKEDEPEND
  147. #
  148. # Generate dependency file suitable for inclusion in future makes.  Must
  149. # mung the dependency file in two ways:  a) add a .md prefix on all the .o
  150. # file names;  b) for each entry for a .o file, generate an equivalent
  151. # entry for a .po file.
  152.  
  153. MAKEDEPEND    : .USE
  154.     @$(TOUCH) $(DEPFILE)
  155.     $(MAKEDEPEND) $(CFLAGS:M-[ID]*) -m $(TM) -w50 -f $(DEPFILE) $(.ALLSRC)
  156.     @$(MV) -f $(DEPFILE) $(DEPFILE).tmp
  157.     @$(SED) -e '/^#/!s|^\([^:]*\)\.o[     ]*:|$(TM).md/\1.po $(TM).md/&|' <$(DEPFILE).tmp > $(DEPFILE)
  158.     @$(RM) -f $(DEPFILE).tmp
  159.  
  160. #if !defined(no_targets)
  161. #
  162. # We should define the main targets (make, make install, etc.).
  163. #
  164.  
  165. default                : $(TM).md/linked.o
  166. $(TM).md/linked.o        : $(OBJS)
  167.     $(RM) -f $(.TARGET)
  168.     $(LD) $(LDFLAGS) -r $(.ALLSRC) -o $(.TARGET)
  169.  
  170. clean                ::
  171.     $(RM) -f $(CLEANOBJS) $(CLEANOBJS:S/.o$/.po/g) $(TM).md/linked.o \
  172.         $(TM).md/linked.po *~ $(TM).md/*~
  173.  
  174. DEPFILE = $(TM).md/dependencies.mk
  175. depend            : $(DEPFILE)
  176. $(DEPFILE)        ! $(SRCS:M*.c) $(SRCS:M*.s) $(SRCS:M*.cc) MAKEDEPEND
  177.  
  178. install                :: default
  179.  
  180. # Name of module lint library.
  181. MODLINTLIB    = llib-l$(NAME).ln
  182.  
  183. lint                : $(TM).md/lint
  184. $(TM).md/lint            : $(CSRCS) ../$(TM).md/lintlib.ln
  185.     $(RM) -f $(.TARGET)
  186.     $(LINT) $(LINTFLAGS) $(CFLAGS:M-[IDU]*) $(.ALLSRC) \
  187.         > $(.TARGET) 2>& 1
  188.  
  189. lintlib            :: $(TM).md/$(MODLINTLIB)
  190. $(TM).md/$(MODLINTLIB)    : $(CSRCS) $(HDRS)
  191.     $(RM) -f $(.TARGET)
  192.     $(LINT) -C$(NAME) $(CFLAGS:M-[IDU]*) -DLINTLIB $(LINTFLAGS) $(.ALLSRC:M*.c)
  193.     $(MV) $(MODLINTLIB) $(.TARGET)
  194.  
  195. mkmf                !
  196.     mkmf
  197.  
  198. newtm                    ! .SILENT
  199.     if $(TEST) -d $(TM).md; then
  200.         true
  201.     else
  202.         mkdir $(TM).md;
  203.         chmod 775 $(TM).md;
  204.         mkmf -m$(TM)
  205.     fi
  206.  
  207. profile                : $(TM).md/linked.po
  208. $(TM).md/linked.po: $(POBJS)
  209.     $(RM) -f $(.TARGET)
  210.     $(LD) $(LDFLAGS) -r $(.ALLSRC) -o $(.TARGET)
  211.  
  212. tags                :: $(ALLCSRCS) $(HDRS)
  213.     $(CTAGS) $(CTFLAGS) $(ALLCSRCS)
  214.  
  215. DISTFILES    ?=
  216.  
  217. dist        !
  218. #if defined(DISTDIR) && !empty(DISTDIR)
  219.     for i in Makefile local.mk $(TM).md/md.mk $(SRCS) $(HDRS) $(DISTFILES)
  220.     do
  221.     if $(TEST) -e $${i}; then
  222.         $(UPDATE)  $${i} $(DISTDIR)/$${i}; else true ; fi
  223.     done
  224. #else
  225.     @echo "Sorry, no distribution directory defined"
  226. #endif
  227.  
  228. #include    <all.mk>
  229.  
  230. #endif no_targets
  231.  
  232. .MAKEFLAGS    : -C        # No compatibility needed
  233.